package com.yzh.oop8.teacher;

public class BookPublisherAuthorComparator implements Comparator {
    @Override
    public int compare(Object obj1, Object obj2) {
        Book book1 =(Book)obj1;
        Book book2 =(Book)obj2;
        int result = book1.getPublisher().compareTo(book2.getPublisher());
        if(result !=0){
            return result;
        }else{
            //如果出版社相同，比较作者
            return book1.getAuthor().compareTo(book2.getAuthor());
        }
    }
}
